unit FiagWinSys;

interface

function GetCurrentProcessMemSize: Integer;

implementation

uses PSAPI, Windows;

{
  Function : Get current process memory usage (in Byte);
  LastModify: 20061116
}

function GetCurrentProcessMemSize: Integer;
var
  PMC: PPROCESS_MEMORY_COUNTERS;
  hPID: HWND;
  l: DWORD;
  bRet: boolean;
begin
  hPID := GetCurrentProcess();
  New(PMC);
  l := SizeOf(PMC^);
  ZeroMemory(PMC, l);
  bRet := GetProcessMemoryInfo(hPID, PMC, l);
  if bRet then
    Result := PMC^.WorkingSetSize
  else
    Result := -1;
  Dispose(PMC);
end;

end.

